package com.cw.jeeyt.dao.impl.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.cw.jeeyt.common.Order;
import com.cw.jeeyt.dao.intf.api.ApiFacadeMethodDao;
import com.cw.jeeyt.dao.mapper.api.ApiFacadeMethodMapper;
import com.cw.jeeyt.dao.model.api.ApiFacadeMethodDo;
import com.cw.lang.common.utils.PageUtil;
import com.cw.lang.common.pagehelper.PageHelper;
import com.cw.lang.mybatis.dto.PageInfo;

/**
 * api接口方法 dao数据库操作接口
 *
 * @author chenw
 * @version 1.0.0
 */
@Repository
public class ApiFacadeMethodDaoImpl implements ApiFacadeMethodDao {
    @Autowired
    private ApiFacadeMethodMapper apiFacadeMethodMapper;

    /**
     * 新增api接口方法
     *
     * @param apiFacadeMethod
     * @return 整数
     */
    public Integer insert(ApiFacadeMethodDo apiFacadeMethod) {
        return apiFacadeMethodMapper.insert(apiFacadeMethod);
    }

    /**
     * 新增api接口方法不为空的字段
     *
     * @param apiFacadeMethod
     * @return 整数
     */
    public Integer insertSelective(ApiFacadeMethodDo apiFacadeMethod) {
        return apiFacadeMethodMapper.insertSelective(apiFacadeMethod);
    }

    /**
     * 删除api接口方法
     *
     * @param apiFacadeMethod
     */
    public void delete(ApiFacadeMethodDo apiFacadeMethod) {
        apiFacadeMethodMapper.delete(apiFacadeMethod);
    }

    /**
     * 修改api接口方法不为null的字段
     *
     * @param apiFacadeMethod
     */
    public void updateSelective(ApiFacadeMethodDo apiFacadeMethod) {
        apiFacadeMethodMapper.updateSelective(apiFacadeMethod);
    }

    /**
     * 修改api接口方法
     *
     * @param apiFacadeMethod
     */
    public void update(ApiFacadeMethodDo apiFacadeMethod) {
        apiFacadeMethodMapper.update(apiFacadeMethod);
    }

    /**
     * 根据主键查询api接口方法
     *
     * @return api接口方法
     */
    public ApiFacadeMethodDo getById(Long id) {
        return apiFacadeMethodMapper.getById(id);
    }

    /**
     * 查询所有api接口方法
     *
     * @return api接口方法集合
     */
    public List<ApiFacadeMethodDo> queryApiFacadeMethodList() {
        return apiFacadeMethodMapper.queryApiFacadeMethodList();
    }

    /**
     * 分页查询api接口方法
     *
     * @param apiFacadeMethod 查询条件
     * @param startRow 开始条数
     * @param pageSize 每页长度
     * @return api接口方法集合
     */
    public PageInfo<ApiFacadeMethodDo> queryByPage(ApiFacadeMethodDo apiFacadeMethod, Integer startRow,
        Integer pageSize, Order order) {
        PageHelper.startPage(PageUtil.calPageNum(startRow, pageSize), pageSize);
        return new PageInfo<>(apiFacadeMethodMapper.queryByPage(apiFacadeMethod, order));
    }

    /**
     * 根据接口文档id查询接口方法
     *
     * @param docId
     * @return
     * @throws Exception
     */
    public List<ApiFacadeMethodDo> queryListByDocId(Long docId) {
        return apiFacadeMethodMapper.queryListByDocId(docId);
    }

    /**
     * 批量保存接口文档信息
     *
     * @param apiMethodList
     * @throws Exception
     */
    public void insertBat(List<ApiFacadeMethodDo> apiMethodList) {
        apiFacadeMethodMapper.insertBat(apiMethodList);
    }
}
